package de.rj.urwalking.ui.fragments;

import java.util.ArrayList;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.actionbarsherlock.app.SherlockFragment;

import de.rj.urwalking.R;
import de.rj.urwalking.data.survey.Question;
import de.rj.urwalking.util.Util;

/**
 * 
 * @author rjj
 *
 */
public class QuestionsFragment extends SherlockFragment {


	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

		ArrayList<Question> questions = (ArrayList<Question>) getArguments().getSerializable("questions");

		View root = inflater.inflate(R.layout.fragment_question, container, false);
		LinearLayout questionsLayout = (LinearLayout) root.findViewById(R.id.questionsLayout);
		
		long timestamp = System.currentTimeMillis();
		

		for (Question q : questions) {
			
			q.setStartTime(timestamp);

			questionsLayout.addView(q.buildView(getActivity(), questionsLayout));
			
			View horizontalDivider = inflater.inflate(R.layout.horizontal_divider, questionsLayout, false);
			questionsLayout.addView(horizontalDivider);

		}
		Util.setupTouchListeners(root, getActivity());
		return root;

	}
	
	
	
	

}
